#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    setUI();
}

Widget::~Widget()
{
}

void Widget::setUI()
{
    //设置窗口尺寸
    this->setMinimumSize(900, 500);
    //设置标题栏
    this->setWindowIcon(QIcon(":/icon/red_mush.png"));
    this->setWindowTitle("PickingRobot Control Panel");

    QVBoxLayout *vbox = new QVBoxLayout;

    //选项卡菜单
    QHBoxLayout *hbox_top = new QHBoxLayout;
    QPushButton *bt1_controlPage = new QPushButton("机械控制");
    QPushButton *bt2_visionPage = new QPushButton("视觉识别");
    QButtonGroup *btns = new QButtonGroup;
    btns->addButton(bt1_controlPage, 0);
    btns->addButton(bt2_visionPage, 1);
    hbox_top->addWidget(bt1_controlPage);
    hbox_top->addWidget(bt2_visionPage);

    //展示内容
    func_pages = new QStackedWidget;
    //机械控制组件
    RobotControlWidget *botController = new RobotControlWidget;
    func_pages->addWidget(botController);
    //视觉识别组件
    VisionMonitorWidget *visionMonitor = new VisionMonitorWidget;
    func_pages->addWidget(visionMonitor);

    vbox->addLayout(hbox_top);
    vbox->addWidget(func_pages);
    this->setLayout(vbox);

    //信号槽
    connect(btns, SIGNAL(buttonClicked(int)), this, SLOT(option_btn_clicked(int)));
}

void Widget::option_btn_clicked(int id)
{
    func_pages->setCurrentIndex(id);
}

